#ifndef __Eventfd_H__
#define __Eventfd_H__
#include <functional>

using EventCallback=std::function<void()>;

class Eventfd
{
public:
    Eventfd(EventCallback && cb);
    ~Eventfd();
    void start();
    void wakeup();
    void stop();
private:
    void handleRead();

    int createEventfd();
    int createEpollFd();
    void addEpollReadFd();

private:
    bool _isLooping;
    int _eventfd;
    int _epfd;
    EventCallback _cb;
};


#endif

